package com.alex.action;

import java.util.List;
import com.opensymphony.xwork2.ActionSupport;
import com.alex.service.IBoardService;
import com.alex.entity.Board;

public class BoardAction extends ActionSupport {
	private static final long serialVersionUID = 1L;
	private String boardname;
	private int parentId;
	private int boardId;
	private List parentboard;
	private IBoardService boardService;
	
	public IBoardService getBoardService() {
		return boardService;
	}

	public void setBoardService(IBoardService boardService) {
		this.boardService = boardService;
	}

	public List getParentboard() {
		return parentboard;
	}

	public void setParentboard(List parentboard) {
		this.parentboard = parentboard;
	}

	public int getBoardId() {
		return boardId;
	}

	public void setBoardId(int boardId) {
		this.boardId = boardId;
	}

	public String getBoardname() {
		return boardname;
	}

	public void setBoardname(String boardname) {
		this.boardname = boardname;
	}

	public int getParentId() {
		return parentId;
	}

	public void setParentId(int parentId) {
		this.parentId = parentId;
	}

	/**
	 * 查找父板块
	 * 
	 * @return
	 */
	public String findParentBoard() {
	
		parentboard = this.boardService.findparentboard();
		return SUCCESS;
	}

	/**
	 * 添加板块
	 * 
	 * @return
	 * @throws Exception
	 */
	public String addBoard() throws Exception {
		
		Board board = new Board();
		board.setBoardname(boardname);
		board.setParentid(parentId);
	
		boardService.BoardSave(board);
		return SUCCESS;
	}

	/**
	 * 更新板块
	 * 
	 * @return
	 * @throws Exception
	 */
	public String updateBoard() throws Exception {
		Board board = boardService.findBoardByid(boardId);
		board.setBoardname(boardname);
		board.setParentid(parentId);
		boardService.BoardUpdate(board);
		return SUCCESS;
	}

	/**
	 * 删除板块
	 * 
	 * @return
	 * @throws Exception
	 */
	public String deleteBoard() throws Exception {
		
		boardService.BoardDelete(boardId);
		return SUCCESS;
	}
}
